package main

import (
	"fmt"
	"time"
)

func main() {

	//后台运行， 现时当前程序正在运行
	go spinner(time.Millisecond * 100)
	const n = 70
	start := time.Now()
	fibN := fib(n)

	end := time.Now()
	fmt.Printf("\rtime: %v,  Finbon%d:%d\n", end.Sub(start), n, fibN)
}

func spinner(delay time.Duration) {

	for {
		for _, r := range `-\|/` {
			fmt.Printf("\r%c", r)
			time.Sleep(delay)
		}
	}
}

func fib(x int) int {
	if x < 2 {
		return x
	}

	return fib(x-1) + fib(x-2)
}
